package com.example.tliasmanagement.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
@Aspect
public class MyAspect1 {


    @Pointcut("execution(* com.example.tliasmanagement.service.impl.DeptServiceImpl.*(..))")
    public void pc(){
    }

    @Around("pc()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("around before");
        //执行原始方法
        Object result = pjp.proceed();
        log.info("around after");
        return result;
    }

    @Before("pc()")
    public void before(JoinPoint jp) throws Throwable {
        log.info("before");
    }

    @After("pc()")
    public void after() throws Throwable {
        log.info("After");
    }

    @AfterReturning("pc()")
    public void afterReturning() throws Throwable {
        log.info("AfterReturning");
    }

    @AfterThrowing("pc()")
    public void afterThrowing() throws Throwable {
        log.info("AfterThrowing");
    }

}